package com.lingnan.wanxiangxinxun.mapper;

import com.lingnan.wanxiangxinxun.entity.po.Authority;
import com.lingnan.wanxiangxinxun.entity.po.EmpPositionAuthority;
import com.lingnan.wanxiangxinxun.entity.po.Employee;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lingnan.wanxiangxinxun.entity.vo.service.AuthorityVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 * 员工表 Mapper 接口
 * </p>
 *
 * @author swl
 * @since 2025-03-13
 */
public interface EmployeeMapper extends BaseMapper<Employee> {

    List<Employee> getEmployeeListByIds(List<Integer> ids);

    List<Authority> getAuthority(Integer id);

    @Select("select * from emp_position_authority " +
            "where position_id = #{id}")
    List<EmpPositionAuthority> getPositionAuthority(Integer id);

    @Update("update emp_position_authority " +
            "set authority_id = #{value} where position_id = #{positionId} ")
    void setPositionAuthority(Integer positionId, int value);

    @Update("update emp_position_authority " +
            "set authority_id = #{value} where id = #{id} ")
    void updatePositionAuthority(int id, Integer value);

    @Delete("delete from emp_position_authority " +
            "where authority_id = #{value}")
    void delAuthority(int value);

    @Insert("insert into emp_position_authority values(null, #{positionId}, #{authorityId})")
    void insertAuthority(EmpPositionAuthority epa);
}
